<!DOCTYPE html>
<html style="height: 100%" lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>登录</title>
    <link href="../layui/css/layui.css" rel="stylesheet"/>
    <script src="../layui/layui.js"></script>
    <script src="../layui/js/public.js"></script>
</head>
<style type="text/css">
    .login-in:after {
        clear: both;
    }

    .input {
        margin-bottom: 10px;
    }
</style>
<body style="height: 100%">

<div class="layui-fluid" style="height: 100%">
    <div class="layui-row" style="height: 100%">
        <div class="layui-col-md6 layui-col-md-offset3" style=" top: calc(25vh);height: 50%;">
            <div class="layui-row" style="background-color:white;border-radius:15px;height: 100%">

                <div class="layui-col-md6 " style="text-align: center;height: 100%;overflow: hidden">

                    <form class="layui-form " action="" method="post" style="height: 50%;">
                        <div class="layui-input-inline input">
                            <input type="text" name="username" required lay-verify="required"
                                   placeholder="请输入用户名"
                                   autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-input-inline input">
                            <input type="password" name="password" required lay-verify="required"
                                   placeholder="请输入密码"
                                   autocomplete="off" class="layui-input">
                        </div>
                        <div style="clear: both;"></div>
                        <div class="layui-input-inline input">
                            <button class="layui-btn" lay-submit lay-filter="formDemo">登录</button>
                        </div>
                    </form>

                </div>

            </div>
    </div>
    </div>
</div>
<script >
    layui.use('form', function(){
        var $ = layui.$,
            form = layui.form;
        console.log("xxx"+baseurl)

        //监听提交
        form.on('submit(formDemo)', function(data){
            $.ajax({
                url: baseurl + "/login",
                type:"post",
                data:data.field,
                success:function (data) {
                    console.log(data)
                    if(data.code===200){
                        localStorage.setItem("token","Bearer "+data.data.token);
                        window.location.href="role_list.html"
                    }
                }
            });
            return false;
        });


    });
</script>
</body>
</html>